package cn.snailhd.xspay;

import java.io.File;
import java.util.ArrayList;
import java.util.List;

import com.alibaba.fastjson.JSONObject;

import cn.snailhd.utils.file.FileHandle;

public class ReadLogAndDeal {
	
	
	public static void preOrderFail(List<String> list){
		List<String> ll = new ArrayList<String>();
		for(String str :list){
			
			if(str.contains("nel.util.HttpClientUtil [67] - 下单请求返回参数")){
				JSONObject re = new JSONObject();
				str = str.substring(90,str.length()-1);
				str = str.replace("\\", "");
				JSONObject je = JSONObject.parseObject(str);
				String merOrderId = je.getString("merOrderId");
				re.put("merOrderId",merOrderId );
				
				re.put("errorMsg", je.get("errorMsg"));
				String errorCode = je.getString("errorCode");
				re.put("errorCode", errorCode);
				System.out.println(je);
				System.out.println(re);

				if("A0000001".equals(errorCode)){
					//System.out.println(re);
//					System.out.println(errorCode+"\t"+merOrderId);
				}
				
				
			}
		}
		

		
	}
	
	public static void main(String[] args) {
		File file = new File("/Users/snailhd/Desktop/mylog-2018-06-15.0.log");
		List<String> list = FileHandle.readText2Line(file, "utf-8");
		preOrderFail(list);
	}

}
